package com.yesjpt.test;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yesjpt.domain.Dog;
import com.yesjpt.domain.Person;
import com.yesjpt.util.IdUtils;

import java.util.*;

public class Hello {
    //有输出的静态方法
    public static int add(int i, int j) {
        int sum = i + j;
        System.out.println("方法中试图把i变成100");
        i = 100;
        return sum;
    }
    public static void change(int i) {
        System.out.println(i + " += 2函数执行，试图把输入进来的 i + 2，i = " + i);
        i += 2;
    }

    public static void changeStr(String s) {
        s += ", world!";
    }

    //无输出的静态方法
    public static void bark(String v){
        System.out.println(v);
    }
    public static void changeDog(Dog vo) {
        System.out.println("正在修改狗的名字");
        vo.setName("黑娃");
    }
    public static void main(String[] args) {
        Map<String, Object> map = new HashMap<>();
        Set<Person> set = new HashSet<>();
        List<Person> all = new ArrayList<>();
        JSONObject o = new JSONObject();
        JSONArray arr = new JSONArray();
        for(int i = 0; i < 10; i++ ) {
            Person vo = new Person();
            vo.setId(IdUtils.guid());
            vo.setName("name00" + i);
            map.put(vo.getId(),vo);
            o.put(vo.getId(), vo);
            all.add(vo);
            arr.add(o);
            set.add(vo);
        }
        //输出
        for(String key: map.keySet()) {
            System.out.println(map.get(key));
            System.out.println(o.get(key));
        }
        for(int i = 0; i < all.size(); i++ ){
            System.out.println(all.get(i));
            System.out.println(arr.get(i));
        }
        //输出集合只能用遍历
        for(Person p: set) {
            System.out.println(p);
        }
        for(int i = 0; i < all.size(); i++) {
            set.add(all.get(i));
        }
        for(Person p: set) {
            System.out.println(p);
        }
        System.out.println("set.size = " + set.size());
    }

}
